'EViews Programming Code for Hong Kong

wfopen  "C:\Users\Maryam\Desktop\BS Studies\PhD Thesis-II\EViews and STATA Progarm Codes\Chapter-6\Hong Kong.wf1"

'****************************************************************************
'Group Plot for RER_CPI, RER_DEF, rer_def_nt_4 and a_tilde_4
'****************************************************************************
group gA rer_cpi rer_def rer_def_nt_4 a_tilde_4
freeze(group_plot) gA.line(x)
group_plot.setelem(1) lcolor(black) symbol(7) lpat(1)
group_plot.setelem(2) lcolor(black) symbol(4) lpat(1)
group_plot.setelem(3) lcolor(black) symbol(1) lpat(1)
group_plot.setelem(3) lcolor(black)
group_plot.options linepat
group_plot.addtext(t) Real ERs and Productivity Gap (Hong Kong & U.S): 1980-2008
group_plot.addtext(b) Year
group_plot.addtext(l) RER_CPI
group_plot.addtext(l) RER_DEF
group_plot.addtext(l) RER_CPI, RER_DEF & rer_def_nt_4
group_plot.addtext(r) a_tilde_4
'************************************************************
'************************************************************
create y 1980 2008
'importing data from Excel for Hong Kong
import  "C:\Users\Maryam\Desktop\BS Studies\PhD Thesis-II\EViews and STATA Progarm Codes\Chapter-6\Chapter 6.xlsx" range="Hong Kong"
'***************************************************************************************************
'CASE-1: ESTIMATING BALASSA-SAMUELSON EFFECT FOR RER_CPI & a_tilde_4
'***************************************************************************************************
'*************************************************************
'STEP 0: Tests for Unit Root in Individual Time Series
'*************************************************************
'*********************************
'Graph for Hong Kong's RER_CPI
'*********************************
                                        
genr rer_cpi = rer_cpi
freeze(figure_rer_cpi) rer_cpi.line
figure_rer_cpi.addtext(t) rer_cpi (Hong Kong):  1980-2008
figure_rer_cpi.addtext(b) Year
figure_rer_cpi.addtext(l) rer_cpi
figure_rer_cpi.legend(off)
                                                 
'We see from the FIGURE that rer_cpi has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations. 

'************************************************
'ADF Unit Root Test for Hong Kong's RER_CPI
'************************************************
 
freeze(table_6_14_rer_cpi_adf) rer_cpi.uroot(adf,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 3.  The unit root test produces a t-value of -3.00 which is greater than our 5% criterion -3.60.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise.  To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,rer_cpi_adf) rer_cpi.uroot(adf,const,trend,info=sic)
freeze(rer_cpi_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the rer_cpi series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test.  I once again begin by graphing the (differenced) series.
 
genr rer_cpidiff = d(rer_cpi)
freeze(figure_rer_cpidiff) rer_cpidiff.line
figure_rer_cpidiff.addtext(t) drer_cpi (Hong Kong):  1980-2008
figure_rer_cpidiff.addtext(b) Year
figure_rer_cpidiff.addtext(l) Drer_cpi
figure_rer_cpidiff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr rer_cpidiff = d(rer_cpi)
freeze(table_6_14_rer_cpidiff1_adf) rer_cpidiff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =3.  The unit root test produces a t-value of -1.71 which is still greater than our 5% criterion -2.99.  Thus, we may not reject the null of non-stationarity in first differenced series of rer_cpi.  There is no reason to go further.  The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,rer_cpidiff1_adf) rer_cpidiff.uroot(adf,const,info=sic)
freeze(rer_cpidiff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the rer_cpi series is greater than I(1).

'*****************************************************
'DF-GLS Unit Root Test for Hong Kong's RER_CPI
'*****************************************************
 
freeze(table_6_14_rer_cpi_dfgls) rer_cpi.uroot(dfgls,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 3.  The unit root test produces a t-value of -3.49 which is smaller than our 5% criterion -3.19.  Thus, at this point, we may reject the null of unit root.

''Putting it all together, I conclude that the rer_cpi series is I(0), a finding incompatible with my ADF test results.

'*************************************************
'Graph for Hong Kong's Productivity (a_tilde_4)
'*************************************************
                                        
genr a_tilde_4 = a_tilde_4
freeze(figurea_tilde_4) a_tilde_4.line
figurea_tilde_4.addtext(t) a_tilde_4 (Hong Kong):  1980-2008
figurea_tilde_4.addtext(b) Year
figurea_tilde_4.addtext(l) a_tilde_4
figurea_tilde_4.legend(off)
                                                 
'We see from the FIGURE that a_tilde_4 has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations. 

'*******************************************************
'ADF Unit Root Test for Hong Kong's Productivity
'*******************************************************
 
freeze(table_6_14_a_tilde_4_adf) a_tilde_4.uroot(adf,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p =1.  The unit root test produces a t-value of -1.19 which is greater than our 5% criterion -3.59.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise.  To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,a_tilde_4_adf) a_tilde_4.uroot(adf,const,trend,info=sic)
freeze(a_tilde_4_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the a_tilde_4 series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test.  I once again begin by graphing the (differenced) series.
 
genr a_tilde_4diff = d(a_tilde_4)
freeze(figure_a_tilde_4diff) a_tilde_4diff.line
figure_a_tilde_4diff.addtext(t) da_tilde_4 (Hong Kong):  1980-2008
figure_a_tilde_4diff.addtext(b) Year
figure_a_tilde_4diff.addtext(l) Da_tilde_4
figure_a_tilde_4diff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr a_tilde_4diff = d(a_tilde_4)
freeze(table_6_14_a_tilde_4diff1_adf) a_tilde_4diff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =0.  The unit root test produces a t-value of -4.44 which is now smaller than our 5% criterion -2.98.  Thus, we may now reject the null of non-stationarity in first differenced series of a_tilde_4.  There is no reason to go further.  The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,a_tilde_4diff1_adf) a_tilde_4diff.uroot(adf,const,info=sic)
freeze(a_tilde_4diff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the a_tilde_4 series is I(1).

'************************************************************
'DF-GLS Unit Root Test for Hong Kong's Productivity
'************************************************************
 
freeze(table_6_14_a_tilde_4_dfgls) a_tilde_4.uroot(dfgls,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 1.  The unit root test produces a t-value of -1.39 which is greater than our 5% criterion -3.19.  Thus, at this point, we may not reject the null of a unit root.
 
'Now let's see if the series is difference stationary or not

genr a_tilde_4diff = d(a_tilde_4)
freeze(table_6_14_a_tilde_41diff1_dfgls) a_tilde_4diff.uroot(dfgls,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p = 1.  The unit root test produces a t-value of -4.18 which is smaller than our 5% criterion -1.95. Thus, we may reject the null of non-stationarity in first differenced series of a_tilde_4.  

''Putting it all together, I conclude that the a_tilde_4 series is I(1), a finding compatible with my ADF test results.

'*********************************************
'Single Equation Cointegration Methods
'*********************************************

'**********************************************************
''Graph the suspected cointegrated series together
'**********************************************************

'The first step is to plot a graph of the suspected series.  This is very important!

group g1 rer_cpi a_tilde_4
freeze(figure6_14a) g1.line(x)
figure6_14a.setelem(1) lcolor(black) 
figure6_14a.setelem(2) lcolor(black) lpat(8)
figure6_14a.options linepat
figure6_14a.addtext(t) rer_cpi and a_tilde_4 (Hong Kong & U.S): 1980-2008
figure6_14a.addtext(b) Year
figure6_14a.addtext(l) rer_cpi
figure6_14a.addtext(r) a_tilde_4

''*******************************************************
''S1.A.Engle-Granger Approach to Cointegration
'*******************************************************
 
freeze(table_6_14_egc_rer_cpi) g1.coint(method=eg)

'The null hypothesis will not be rejected as suggested by sample statistics.

''******************************************
''S1.B.Error Correction Model (ECM)
'*******************************************
''**********************************************
'Selecting the number of lags in the VAR
'***********************************************

'NOTE: We do this because we need to have the "right" number of lags when it comes time to estimate our VEC model and test for cointegration.

var table_6_14_var1.ls 1 4   g1
freeze(table_6_14_var1_lagtest1) table_6_14_var1.laglen(4)
freeze(table_6_14_var1_lagtest2) table_6_14_var1.testlags

'The laglength test above indicates that the VAR has 4 lags.
 
var table_6_14_var2.ls 1 4  g1
freeze(table_6_14_var2_artest1) table_6_14_var2.correl
freeze(table_6_14_var2_artest2) table_6_14_var2.qstats(12)
freeze(table_6_14_var2_artest3) table_6_14_var2.arlm(12)

'The residuals are absolutely white noise. 

'We now try different lags of d(a_tilde_4), comparing SIC values across specifications.

genr resid = 0
equation eg.ls rer_cpi c a_tilde_4
genr ec1 = resid

var table_6_14_eg2a_cpi.ls 0 0 d(rer_cpi)   @  c ec1(-1) d(rer_cpi(-1)) d(rer_cpi(-2)) d(rer_cpi(-3)) d(rer_cpi(-4)) 

var table_6_14_eg2b_cpi.ls 0 0 d(rer_cpi)   @  c ec1(-1) d(rer_cpi(-1))  d(a_tilde_4(-1)) d(rer_cpi(-2)) d(rer_cpi(-3)) d(rer_cpi(-4)) 

var table_6_14_eg2c_cpi.ls 0 0 d(rer_cpi)   @  c ec1(-1) d(rer_cpi(-1)) d(rer_cpi(-2)) d(rer_cpi(-3)) d(rer_cpi(-4)) d(a_tilde_4(-1)) d(a_tilde_4(-2))

'The evidence suggests that Model C is best.  Now we test that model for serial correlation.

var table_6_14_eg2c_cpi.ls 0 0 d(rer_cpi)   @   c ec1(-1) d(rer_cpi(-1)) d(rer_cpi(-2)) d(rer_cpi(-3)) d(rer_cpi(-4)) d(a_tilde_4(-1)) d(a_tilde_4(-2))
freeze(table_6_14_eg2c1_cpi_artest1) table_6_14_eg2c_cpi.correl
freeze(table_6_14_eg2c2_cpi_artest2) table_6_14_eg2c_cpi.qstats(12)
freeze(table_6_14_eg2c3_cpi_artest3) table_6_14_eg2c_cpi.arlm(12)

'The residuals are absolutely white noise. 

''*************************
''Estimating EC Model  
'**************************

'We'll now take the above specified model and turn it into an ECM. We shall run NW-HAC least squares model for establishing error correction mechanism.

'We now estimate the corresponding ECM:

equation table_6_14_ecm_rer_cpi.ls(n) d(rer_cpi) c ec1(-1) d(rer_cpi(-1)) d(rer_cpi(-2)) d(rer_cpi(-3)) d(rer_cpi(-4)) d(a_tilde_4(-1)) d(a_tilde_4(-2))

'Note that the SR effect is significant as the error correction coefficient -0.13 is statistically significant at 1% significance level.

''**********************************************
''S2.A & S2.B: Obtaining LR Coefficients
'***********************************************
'Now, by employing FMOLS and DOLS cointegration regression estimators, finally we shall calculate our LR coefficient i.e. BS coefficient for Hong ong against U.S.

equation table_6_14_LReqn1a_fmols.cointreg(method=fmols) rer_cpi a_tilde_4

equation table_6_14_LReqn1b_dols.cointreg(method=dols, trend=constant, lag=2,lead=2 ) rer_cpi a_tilde_4

'The BS coefficient obtained through FMOLS and DOLS estimators are 0.17 and 0.20 respectively and are statistically significant. Thus, there is valid evidence in support of BS effect existing for Hong Kong.

''******************************************
'Multivariate Cointegration Approach
'******************************************

''********************************************************
''Check if the VAR (2) model is dynamically stable
'*********************************************************
freeze(table_6_14_var2_varstable) table_6_14_var2.arroots(graph)

'The model is dynamically stable.

''**********************************************************************
''M1.A & M1.B: Identifying the number of cointegrating vectors
'***********************************************************************

'Having identified the appropriate number of lags to put in, I now go on to test for the appropriate number of cointegrating equations.

freeze(table_6_14_var2_coint1) table_6_14_var2.coint(s,4)

'This command estimates all possible combinations of constants and trends in the level data series and the cointegrating equations. All the results indicate 0 cointegrating vectors.
'
'GENERAL NOTE:, in practice, cases 1 and 5 are rarely used. One should use case 1 only if one knows that all series have zero mean. Case 5 may provide a good fit in-sample but will produce implausible forecasts out-of-sample. As a rough guide, use case 2 if none of the series appear to have a trend. For trending series, use case 3 if you believe all trends are stochastic; if you believe some of the series are trend stationary, use case 4.

'Note that the 5 cases are identified under "Johansen cointegration test" in EViews. They run from most restrictive (no constants in either the level series or CEs) to most general (trend terms in both the level series and CEs).

''******************************************************************
''M2.A, M2.B & M3: Vector Error Correction Model (VECM)
'*******************************************************************

' For estimating the LR relationship, corresponding VEC command is:

var table_6_14_vec1c.ec(c,1) 1 3 rer_cpi a_tilde_4

'CONCLUSION:  I conclude that rer_cpi and a_tilde are not cointegrated in the Hong Kong's data.

'***************************************************************************************************
'CASE-2: ESTIMATING BALASSA-SAMUELSON EFFECT FOR RER_DEF & a_tilde_4
'***************************************************************************************************
'*************************************************************
'STEP 0: Tests for Unit Root in Individual Time Series
'*************************************************************
'*********************************
'Graph for Hong Kong's RER_DEF
'*********************************
                                        
genr rer_def = rer_def
freeze(figure_rer_def) rer_def.line
figure_rer_def.addtext(t) rer_def (Hong Kong):  1980-2008
figure_rer_def.addtext(b) Year
figure_rer_def.addtext(l) rer_def
figure_rer_def.legend(off)
                                                 
'We see from the FIGURE that rer_def has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations.  

'*****************************************************
'ADF Unit Root Test for Hong Kong's RER_DEF
'*****************************************************
 
freeze(table_6_14_rer_def_adf) rer_def.uroot(adf,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 1. The unit root test produces a t-value of -2.21 which is greater than our 5% criterion -3.59.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise.  To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,rer_def_adf) rer_def.uroot(adf,const,trend,info=sic)
freeze(rer_def_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise. Putting it all together, I conclude that the rer_def series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test. I once again begin by graphing the (differenced) series.
 
genr rer_defdiff = d(rer_def)
freeze(figure_rer_defdiff) rer_defdiff.line
figure_rer_defdiff.addtext(t) drer_def (Hong Kong):  1980-2008
figure_rer_defdiff.addtext(b) Year
figure_rer_defdiff.addtext(l) drer_def
figure_rer_defdiff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr rer_defdiff = d(rer_def)
freeze(table_6_14_rer_defdiff1_adf) rer_defdiff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =0. The unit root test produces a t-value of -2.91 which is still greater than our 5% criterion -2.93.  Thus, we may not reject the null of non-stationarity in first differenced series of rer_def.  There is no reason to go further.  The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,rer_defdiff1_adf) rer_defdiff.uroot(adf,const,info=sic)
freeze(rer_defdiff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the rer_def series is greater than I(1).

'*****************************************************
'DF-GLS Unit Root Test for Hong Kong's RER_DEF
'*****************************************************
 
freeze(table_6_14a_rer_def_dfgls) rer_def.uroot(dfgls,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 1.  The unit root test produces a t-value of -2.20 which is greater than our 5% criterion -3.19.  Thus, at this point, we may not reject the null of unit root.

'Now let's see if the series is difference stationary or not

genr rer_cpidiff = d(rer_def)
freeze(table_6_14b_rer_defdiff1_dfgls_d) rer_defdiff.uroot(dfgls,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p = 0.  The unit root test produces a t-value of -2.04 which is now smaller than our 5% criterion -1.95. Thus, we may reject the null of non-stationarity in first differenced series of rer_def.  

''Putting it all together, I conclude that the rer_def series is I(1), a finding incompatible with my ADF test results.

'*********************************************
'Single Equation Cointegration Methods
'*********************************************
'**********************************************************
''Graph the suspected cointegrated series together
'**********************************************************

'The first step is to plot a graph of the suspected series.  This is very important!

group g2 rer_def a_tilde_4
freeze(figure6_14b) g2.line(x)
figure6_14b.setelem(1) lcolor(black) 
figure6_14b.setelem(2) lcolor(black) lpat(8)
figure6_14b.options linepat
figure6_14b.addtext(t) rer_def and a_tilde_4 (Hong Kong & U.S): 1980-2008
figure6_14b.addtext(b) Year
figure6_14b.addtext(l) rer_def
figure6_14b.addtext(r) a_tilde_4

''*******************************************************
''S1.A.Engle-Granger Approach to Cointegration
'*******************************************************

freeze(table_6_14_egc_rer_def) g2.coint(method=eg)

'The null hypothesis will not be rejected as suggested by sample statistics.

''******************************************
''S1.B.Error Correction Model (ECM)
'*******************************************

''**********************************************
'Selecting the number of lags in the VAR
'***********************************************

'NOTE: We do this because we need to have the "right" number of lags when it comes time to estimate our VEC model and test for cointegration.

var table_6_14_var3.ls 1 4   g2
freeze(table_6_14_var3_lagtest1) table_6_14_var3.laglen(4)
freeze(tale_6_14_var3_lagtest2) table_6_14_var3.testlags

'The lag length test above indicates that the VAR has 4 lags. 

var table_6_14_var4.ls 1 4  g2
freeze(table_6_14_var4_artest1) table_6_14_var4.correl
freeze(table_6_14_var4_artest2) table_6_14_var4.qstats(12)
freeze(table_6_14_var4_artest3) table_6_14_var4.arlm(12)

'The residuals are absolutely white noise.

'We now try different lags of d(a_tilde_4), comparing SIC values across specifications.

genr resid = 0
equation eg.ls rer_def c a_tilde_4
genr ec2 = resid

var table_6_14_eg2a_def.ls 0 0 d(rer_def)   @  c ec2(-1) d(rer_def(-1)) d(rer_def(-2)) d(rer_def(-3)) d(rer_def(-4)) 

var table_6_14_eg2b_def.ls 0 0 d(rer_def)   @  c ec2(-1) d(rer_def(-1)) d(rer_def(-2)) d(rer_def(-3)) d(rer_def(-4)) d(a_tilde_4(-1))

var table_6_14_eg2c_def.ls 0 0 d(rer_def)   @  c ec2(-1) d(rer_def(-1)) d(rer_def(-2)) d(rer_def(-3)) d(rer_def(-4)) d(a_tilde_4(-1)) d(a_tilde_4(-2))

'The evidence suggests that Model C is best.  Now we test that model for serial correlation.

var table_6_14_eg2c_def.ls 0 0 d(rer_def)   @   c ec2(-1) d(rer_def(-1)) d(rer_def(-2)) d(rer_def(-3)) d(rer_def(-4))  d(a_tilde_4(-1)) d(a_tilde_4(-2))
freeze(table_6_14_eg2c1_def_artest1) table_6_14_eg2c_def.correl
freeze(table_6_14_eg2c2_def_artest2) table_6_14_eg2c_def.qstats(12)
freeze(table_6_14_eg2c3_def_artest3) table_6_14_eg2c_def.arlm(12)

'The residuals are absolutely white noise. 

''*************************
'Estimating EC Model  
'**************************

'We'll now take the above specified model and turn it into an ECM. We shall run NW-HAC least squares model for establishing error correction mechanism.

'We now estimate the corresponding ECM:

equation table_6_14_ecm_rer_def.ls(n) d(rer_def) c ec2(-1) d(rer_def(-1)) d(rer_def(-2)) d(rer_def(-3)) d(rer_def(-4)) d(a_tilde_4(-1)) d(a_tilde_4(-2))

'Note that the SR effect is significant as the error correction coefficient -0.11 is statistically significant at 10% significance level.

''**********************************************
''S2.A & S2.B: Obtaining LR Coefficients
'***********************************************
'Now, by employing FMOLS and DOLS cointegration regression estimators, finally we shall calculate our LR coefficient i.e. BS coefficient for Hong ong against U.S.

equation table_6_14_LReqn2a_fmols.cointreg(method=fmols) rer_def a_tilde_4

equation table_6_14_LReqn2b_dols.cointreg(method=dols, trend=constant, lag=2,lead=2 ) rer_def a_tilde_4

'The BS coefficient obtained through FMOLS and DOLS estimators are 0.12 and 0.20 respectively and are statistically significant. Thus, there is valid evidence in support of BS effect existing for Hong Kong.

''******************************************
'Multivariate Cointegration Approach
'******************************************

''*********************************************************
''Check if the VAR (4) model is dynamically stable
'*********************************************************
freeze(var4_varstable) table_6_14_var4.arroots(graph)

'The model is dynamically stable.

''**********************************************************************
''M1.A & M1.B: Identifying the number of cointegrating vectors
'***********************************************************************

'Having identified the appropriate number of lags to put in, I now go on to test for the appropriate number of cointegrating equations.

freeze(table_6_14_var4_coint2) table_6_14_var4.coint(s,4)

'This command estimates all possible combinations of constants and trends in the level data series and the cointegrating equations. Trace statistic of Case 3 indicate 1 cointegrating vector.
'
'GENERAL NOTE:, in practice, cases 1 and 5 are rarely used. One should use case 1 only if one knows that all series have zero mean. Case 5 may provide a good fit in-sample but will produce implausible forecasts out-of-sample. As a rough guide, use case 2 if none of the series appear to have a trend. For trending series, use case 3 if you believe all trends are stochastic; if you believe some of the series are trend stationary, use case 4.

'Note that the 5 cases are identified under "Johansen cointegration test" in EViews. They run from most restrictive (no constants in either the level series or CEs) to most general (trend terms in both the level series and CEs).

''******************************************************************
''M2.A, M2.B & M3: Vector Error Correction Model (VECM)
'*******************************************************************

' For estimating the LR relationship, corresponding VEC command is:

var table_6_14_vec2c.ec(c,1) 1 3 rer_def a_tilde_4

'CONCLUSION:  I conclude that rer_def and a_tilde are not cointegrated in the Hong Kong's data.

'********************************************************************************************************
'CASE-3: ESTIMATING BALASSA-SAMUELSON EFFECT FOR rer_def_nt_4 & a_tilde_4
'********************************************************************************************************
'*************************************************************
'STEP 0: Tests for Unit Root in Individual Time Series
'*************************************************************
'******************************************
'Graph for Hong Kong's rer_def_nt_4
'******************************************
                                        
genr rer_def_nt_4 = rer_def_nt_4
freeze(figure_rer_def_nt_4) rer_def_nt_4.line
figure_rer_def_nt_4.addtext(t) rer_def_nt_4 (Hong Kong):  1980-2008
figure_rer_def_nt_4.addtext(b) Year
figure_rer_def_nt_4.addtext(l) rer_def_nt_4
figure_rer_def_nt_4.legend(off)
                                                 
'We see from the FIGURE that rer_def_nt_4 has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations. 

'******************************************************
'ADF Unit Root Test for Hong Kong's rer_def_nt_4
'******************************************************
 
freeze(table_6_14_rer_def_nt_4_adf) rer_def_nt_4.uroot(adf,trend,lag=2)

'Note that I had to specify lags, p = 2 to obtain white residuals from unit root test regression. The unit root test produces a t-value of -2.48 which is greater than our 5% criterion -3.59.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise. To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,rer_def_nt_4_adf) rer_def_nt_4.uroot(adf,const,trend,lag=2)
freeze(rer_def_nt_4_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the rer_def_nt_4 series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test.  I once again begin by graphing the (differenced) series.
 
genr rer_def_nt_4diff = d(rer_def_nt_4)
freeze(figure_rer_def_nt_4diff) rer_def_nt_4diff.line
figure_rer_def_nt_4diff.addtext(t) drer_def_nt_4 (Hong Kong):  1980-2008
figure_rer_def_nt_4diff.addtext(b) Year
figure_rer_def_nt_4diff.addtext(l) drer_def_nt_4
figure_rer_def_nt_4diff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr rer_def_nt_4diff = d(rer_def_nt_4)
freeze(table_6_14_rer_def_nt_4diff1_adf) rer_def_nt_4diff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =0.  The unit root test produces a t-value of -2.50 which is still greater than our 5% criterion -2.97.  Thus, we may not reject the null of non-stationarity in first differenced series of rer_def_nt_4.  There is no reason to go further.  The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,rer_def_nt_4diff1_adf) rer_def_nt_4diff.uroot(adf,const,info=sic)
freeze(rer_def_nt_4diff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise. Putting it all together, I conclude that the rer_def_nt_4 series is greater than I(1).

'**************************************************************
'DF-GLS Unit Root Test for Hong Kong's rer_def_nt_4
'**************************************************************
 
freeze(table_6_14a_rer_def_nt_4_dfgls) rer_def_nt_4.uroot(dfgls,trend,lag=2)

'Note that I had to specify lags, p = 2 to obtain white residuals from unit root test regression. The unit root test produces a t-value of -2.86 which is greater than our 5% criterion -3.19. Thus, at this point, we may not reject the null of a unit root. 

'Now let's see if the series is difference stationary or not

Genr rer_def_nt_4diff = d(rer_def_nt_4)
freeze(table_6_14b_rer_def_nt_41diff1_dfgls) rer_def_nt_4diff.uroot(dfgls,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p = 0.  The unit root test produces a t-value of -2.42 which is now smaller than our 5% criterion -1.95. Thus, we may reject the null of non-stationarity in first differenced series of rer_def_nt_4.  

''Putting it all together, I conclude that the rer_def_nt_4 series is I(1), a finding incompatible with my ADF test results.

'*********************************************
'Single Equation Cointegration Methods
'*********************************************

'**********************************************************
''Graph the suspected cointegrated series together
'**********************************************************

'The first step is to plot a graph of the suspected series.  This is very important!

group g3 rer_def_nt_4 a_tilde_4
freeze(figure6_14) g3.line(x)
figure6_14.setelem(1) lcolor(black) 
figure6_14.setelem(2) lcolor(black) lpat(8)
figure6_14.options linepat
figure6_14.addtext(t) rer_def_nt_4 and a_tilde_4 (Hong Kong & U.S): 1980-2008
figure6_14.addtext(b) Year
figure6_14.addtext(l) rer_def_nt_4
figure6_14.addtext(r) a_tilde_4

''*******************************************************
''S1.A.Engle-Granger Approach to Cointegration
'*******************************************************
 
freeze(table_6_14_egc_rer_def_nt_4) g3.coint(method=eg)

'The null hypothesis will not be rejected as suggested by sample statistics. 

''******************************************
''S1.B.Error Correction Model (ECM)
'*******************************************
''**********************************************
'Selecting the number of lags in the VAR
'***********************************************

'NOTE: We do this because we need to have the "right" number of lags when it comes time to estimate our VEC model and test for cointegration.

var table_6_14_var5.ls 1 6   g3
freeze(table_6_14_var5_lagtest1) table_6_14_var5.laglen(4)
freeze(tale_6_14_var5_lagtest2) table_6_14_var5.testlags

'The lag length test above indicates that the VAR has 4 lags. 

var table_6_14_var6.ls 1 4  g3
freeze(table_6_14_var6_artest1) table_6_14_var6.correl
freeze(table_6_14_var6_artest2) table_6_14_var6.qstats(12)
freeze(table_6_14_var6_artest3) table_6_14_var6.arlm(12)

'The residuals are absolutely white noise. 

'We now try different lags of d(a_tilde_4), comparing SIC values across specifications.

genr resid = 0
equation eg.ls rer_def_nt_4 c a_tilde_4
genr ec3 = resid

var table_6_14_eg2a_def_nt.ls 0 0 d(rer_def_nt_4)   @  c ec3(-1) d(rer_def_nt_4(-1)) d(rer_def_nt_4(-2)) d(rer_def_nt_4(-3)) d(rer_def_nt_4(-4)) 

var table_6_14_eg2b_def_nt.ls 0 0 d(rer_def_nt_4)   @  c ec3(-1) d(rer_def_nt_4(-1)) d(rer_def_nt_4(-2)) d(rer_def_nt_4(-3)) d(rer_def_nt_4(-4)) d(a_tilde_4(-1))

var table_6_14_eg2c_def_nt.ls 0 0 d(rer_def_nt_4)   @  c ec3(-1) d(rer_def_nt_4(-1)) d(rer_def_nt_4(-2)) d(rer_def_nt_4(-3)) d(rer_def_nt_4(-4)) d(a_tilde_4(-1)) d(a_tilde_4(-2))

'The evidence suggests that Model A is best.  

var table_6_14_eg2a_def_nt.ls 0 0 d(rer_def_nt_4)   @   c ec2(-1) d(rer_def(-1))  d(rer_def_nt_4(-2)) d(rer_def_nt_4(-3)) d(rer_def_nt_4(-4))
freeze(table_6_14_eg2a1_def_nt_artest1) table_6_14_eg2a_def_nt.correl
freeze(table_6_14_eg2a2_def_nt_artest2) table_6_14_eg2a_def_nt.qstats(12)
freeze(table_6_14_eg2a3_def_nt_artest3) table_6_14_eg2a_def_nt.arlm(12)

'The residuals are absolutely white noise.  

''*************************
'Estimating EC Model  
'**************************

'We'll now take the above specified model and turn it into an ECM. We shall run NW-HAC least squares model for establishing error correction mechanism.

'We now estimate the corresponding ECM:

equation table_6_14_ecm_rer_def_nt_4.ls(n) d(rer_def_nt_4) c ec3(-1) d(rer_def_nt_4(-1)) d(rer_def_nt_4(-2)) d(rer_def_nt_4(-3)) d(rer_def_nt_4(-4))

'Note that the SR effect is insignificant as the error correction coefficient -0.01 is statistically insignificant even at 10% significance level.

''**********************************************
''S2.A & S2.B: Obtaining LR Coefficients
'***********************************************
'Now, by employing FMOLS and DOLS cointegration regression estimators, finally we shall calculate our LR coefficient i.e. BS coefficient for Hong ong against U.S.

equation table_6_14_LReqn3a_fmols.cointreg(method=fmols) rer_def_nt_4 a_tilde_4

equation table_6_14_LReqn3b_dols.cointreg(method=dols, trend=constant, lag=2,lead=2 ) rer_def_nt_4 a_tilde_4

'The BS coefficient obtained through FMOLS and DOLS estimators are 0.08 and 0.13 and are statistically insignificant and significant respectively. Thus, there is 'Mixed' evidence in support of BS effect existing for Hong Kong.

''******************************************
'Multivariate Cointegration Approach
'******************************************

''********************************************************
''Check if the VAR (6) model is dynamically stable
'*********************************************************
freeze(var6_varstable) table_6_14_var6.arroots(graph)

'The model is dynamically stable.

''**********************************************************************
''M1.A & M1.B: Identifying the number of cointegrating vectors
'***********************************************************************

'Having identified the appropriate number of lags to put in, I now go on to test for the appropriate number of cointegrating equations.

freeze(table_6_14_var6_coint3) table_6_14_var6.coint(s,4)

'This command estimates all possible combinations of constants and trends in the level data series and the cointegrating equations. Trace statistic of Case 3 indicate 1 cointegrating vector.
'
'GENERAL NOTE:, in practice, cases 1 and 5 are rarely used. One should use case 1 only if one knows that all series have zero mean. Case 5 may provide a good fit in-sample but will produce implausible forecasts out-of-sample. As a rough guide, use case 2 if none of the series appear to have a trend. For trending series, use case 3 if you believe all trends are stochastic; if you believe some of the series are trend stationary, use case 4.

'Note that the 5 cases are identified under "Johansen cointegration test" in EViews. They run from most restrictive (no constants in either the level series or CEs) to most general (trend terms in both the level series and CEs).

''******************************************************************
''M2.A, M2.B & M3: Vector Error Correction Model (VECM)
'*******************************************************************

' For estimating the LR relationship, corresponding VEC command is:

var table_6_14_vec3c.ec(c,1) 1 3 rer_def_nt_4 a_tilde_4

'CONCLUSION:  I conclude that rer_def_nt_4 and a_tilde_4 are not cointegrated in the Hong Kong data.


